<?php
class Database {
    private static $_config;

    /**
     * @var \PDO
     */
    private static $_instance = null;

    public static function setConfig($config) {
        self::$_config = $config;
    }

    public static function getInstance() {
        if (self::$_instance === null) {
            $config = self::$_config;
            $filename = realpath($config['dbname']);
            self::$_instance = new PDO('sqlite:'.$filename);
            self::$_instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        }
        return self::$_instance;
    }
}
